package com.springboot.controller;


import com.springboot.common.Result;
import com.springboot.entity.Admin;
import com.springboot.service.AdminService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 管理员相关模块;
 */
@RestController
@RequestMapping("/shop")
@Api(tags = "管理员模块",value = "管理员登录")
public class AdminController {

    @Autowired
    AdminService adminService;

    /**
     *
     * @param admin
     * @return
     */
    @PostMapping("/login")
    @ApiOperation(value = "管理员登录",httpMethod = "POST")
    public Result AdminLogin(@RequestBody Admin admin){
        Admin admin1=adminService.AdminLogin(admin);
        if(admin1!=null){
            return Result.success("管理员登录成功",admin1);
        }else {
            return Result.fail(505,"用户名或者密码错误", null);
        }
    }
}
